<?php
	class Admbooksmodel extends CI_Model{
		//图书分页
		public function page_list($start,$total) {
			$this->load->database();
			return $this->db->query("select * from books limit $start,$total")->result_array();
			//$query = $this->db->get('christian_books', $num, $offset);  
		}
		//增加图书
		public function book_add($data){
			$this->load->database();
			$result = $this->db->insert("books",$data);
			return $result;
		}
		//图书Id查询
		public function book_row($data){
			$this->load->database();
			$result = $this->db->query("select * from books where ISBN='$data'")->result();
			return $result;
		}
		//更新图书
		public function book_save($id,$datas){
			$this->load->database();
			// $query = $this->db->where(array('id'=>$id))->update('user',$datas);
			 $query = $this->db->update('books',$datas,array('id'=>$id));
        	return $query;
		}
		//id查询
		public function book_id($data){
			$this->load->database();
			$result = $this->db->query("select * from books where Book_ID='$data'");
			return $result->row_array();
		}
		//删除图书
		public function book_dele($data){
			$this->load->database();
			return $this->db->delete('books',array('Book_ID'=>$data));

		}
		//模糊查询
		public function book_vague($data){
			$this->load->database();
			$result=$this->db->query("select * from books where Title like '%".$data."%'");
			//result_array()  和row_array() 用法一定要记住  result_array()返回时全部数据  row_array()返回第一条数据
			return $result->result_array();
		}
	}
?>